package com.wcpdoc.exam.core.dao.impl;

import com.wcpdoc.core.dao.impl.RBaseDaoImpl;
import com.wcpdoc.core.entity.PageIn;
import com.wcpdoc.core.entity.PageOut;
import com.wcpdoc.exam.core.dao.MyMockQuestionDao;
import com.wcpdoc.exam.core.entity.MyMockQuestion;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 我的模拟试题数据访问层实现
 * 
 */
@Repository
public class MyMockQuestionDaoImpl extends RBaseDaoImpl<MyMockQuestion> implements MyMockQuestionDao {

	@Override
	public PageOut getListpage(PageIn pageIn) {
		return null;
	}

	@Override
	public List<MyMockQuestion> getList(Integer examId, Integer userId) {
		String sql = "SELECT * FROM EXM_MY_EXAM_MOCK_QUESTION WHERE MOCK_EXAM_ID = :EXAM_ID AND USER_ID = :USER_ID ORDER BY NO";
		return getList(sql, new Object[] { examId, userId }, MyMockQuestion.class);
	}

	@Override
	public MyMockQuestion getMyMockQuestion(Integer examId, Integer userId, Integer questionId) {
		String sql = "SELECT * FROM EXM_MY_EXAM_MOCK_QUESTION WHERE MOCK_EXAM_ID = :EXAM_ID AND USER_ID = :USER_ID AND QUESTION_ID = :QUESTION_ID";
		return getEntity(sql, new Object[] { examId, userId, questionId });
	}

	@Override
	public void clear(Integer examId) {
		String sql = "DELETE FROM EXM_MY_EXAM_MOCK_QUESTION WHERE MOCK_EXAM_ID = :EXAM_ID";
		update(sql, new Object[] { examId });
	}
}